<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void
    {
        Schema::table('freelancers', function (Blueprint $table) {
            if (! Schema::hasColumn('freelancers', 'id_card_recognition_status')) {
                $table->enum('id_card_recognition_status', ['pending', 'approved', 'rejected'])
                    ->default('pending')
                    ->comment('身份证识别状态')
                    ->after('verification_status');
            }

            if (! Schema::hasColumn('freelancers', 'face_recognition_status')) {
                $table->enum('face_recognition_status', ['pending', 'approved', 'rejected'])
                    ->default('pending')
                    ->comment('人脸识别状态')
                    ->after('id_card_recognition_status');
            }
        });
    }

    public function down(): void
    {
        Schema::table('freelancers', function (Blueprint $table) {
            if (Schema::hasColumn('freelancers', 'face_recognition_status')) {
                $table->dropColumn('face_recognition_status');
            }
            if (Schema::hasColumn('freelancers', 'id_card_recognition_status')) {
                $table->dropColumn('id_card_recognition_status');
            }
        });
    }
};
